package pile.pay.service.impl;

import pile.pay.entity.GrantPower;
import pile.pay.mapper.GrantPowerMapper;
import pile.pay.service.IGrantPowerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import pile.pay.entity.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import pile.pay.utils.WebUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import pile.pay.entity.PageList;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import pile.pay.params.grantPower.DeleDTO;
import pile.pay.params.grantPower.ListDTO;
/**
 * <p>
 * 发放电量 服务实现类
 * </p>
 *
 * @author 郭天义
 * @since 2024-06-29
 */
@Service
public class GrantPowerServiceImpl extends ServiceImpl<GrantPowerMapper, GrantPower> implements IGrantPowerService {

    @Autowired
    private GrantPowerMapper grantPowerMapper;


   @Override
   public ResponseResult add(GrantPower grantPower) {
        grantPowerMapper.insert(grantPower);
        return new ResponseResult(200,"新增成功");
   }

    /**
     * 查询用户在该场站下的免费电量  根据电站ID 用户ID 渠道查询  免费电
     * @param memberId
     * @param stationId
     * @param channel
     * @return
     */
    @Override
    public GrantPower selectByMemberIdAndStationId(Integer memberId, Integer stationId,Integer channel) {
        GrantPower grantPower = grantPowerMapper.selectByMemberIdAndStationId(memberId, stationId,channel);
        return grantPower;
    }

    /**
     * 根据免费电ID 修改免费电 +
     * @param givePower
     * @param grantPowerId
     */
    @Override
    public void updatePower(Integer givePower, Integer grantPowerId) {
        grantPowerMapper.updatePower(givePower,grantPowerId);

    }


}
